import axios from 'axios'
// import { Toast } from 'vant'
// import router from '@/router/index'
const request = axios.create({
  baseURL: 'http://liufusong.top:8080'
  // timeout: 30000
})

request.interceptors.request.use(config => {
  const token = localStorage.getItem('MY-HK-TOKEN')
  config.headers.authorization = token
  return config
}, err => {
  return Promise.reject(err)
})

request.interceptors.response.use(response => {
  return response.data
}, err => {
  console.log(err)
  // if (err.response.status === 400) {
  //   localStorage.removeItem('MY-HK-TOKEN')
  //   router.push('/login')
  // } else {
  //   Toast(err.response.data.message)
  // }
  return Promise.reject(err)
})

export default request
